/*******************************************************************************
**
**     Copyright 2016 GSST, Inc.
**
**     Filename    : GSStm32F4_trigTable.h
**     Project     : elecDeskVST
**     Processor   : STM32F103C8
**     Author      : GSST
**     Version     : Driver 01.00
**     Compiler    : IAR C Compiler
**     Date/Time   : 2016-10-16, 13:51
**
** ###################################################################*/

#ifndef _GS_TRIG_TAB_H
#define _GS_TRIG_TAB_H

#include "GSStm32F4_includes.h"

#define GS_ANGLE_MAX 2048
#define GS_TAN_ANGLE_MAX 450

#define GS_GET_TRIG_VAL(GS_DF_TRIGPTR, GS_DF_THETA) \
    {\
        GS_DF_TRIGPTR.d_sin = s_sinTable[GS_DF_THETA]; \
        GS_DF_TRIGPTR.d_cos = s_cosTable[GS_DF_THETA]; \
    }

#define GS_GET_TAN_VAL(GS_DF_PTR, GS_DF_THETA) \
    {\
        if (GS_DF_THETA < GS_TAN_ANGLE_MAX) \
            {GS_DF_PTR = s_tanTable[GS_DF_THETA];} \
        else \
            {GS_DF_PTR = 1.0f / s_tanTable[900 - GS_DF_THETA];} \
    }

typedef struct{
    _FLOAT d_sin;
    _FLOAT d_cos;
} _TRIGVAL;

extern _FLOAT s_sinTable[GS_ANGLE_MAX + 1];
extern _FLOAT s_cosTable[GS_ANGLE_MAX + 1];
extern _FLOAT s_tanTable[GS_TAN_ANGLE_MAX + 1]; // 0.1angle 0-45angle
extern _FLOAT c_angleCompTable[GS_TAN_ANGLE_MAX + 1];

#endif

